New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[eslint] Allow "latest"
as ecmaVersion
#13638
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/48262/ |
@@ -11,7 +11,7 @@ exports.normalizeESLintConfig = function (options) { | |||
|
|||
return { | |||
babelOptions: { cwd: process.cwd(), ...babelOptions }, | |||
ecmaVersion, | |||
ecmaVersion: ecmaVersion === 'latest' ? 2020 : ecmaVersion, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it throw if we just directly pass "latest"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, I can't find where it's used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But yes, if we use "latest"
, the parser throws https://github.com/sindresorhus/eslint-plugin-unicorn/pull/1465/checks?check_run_id=3248815028#step:5:18825
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint-scope
does not support 'latest'
as valid. Does is make more sense to update it there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint-scope
suggest handling on parser side. eslint/eslint-scope#74 (comment)
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit fb7cdea:
|
@@ -11,7 +11,7 @@ exports.normalizeESLintConfig = function (options) { | |||
|
|||
return { | |||
babelOptions: { cwd: process.cwd(), ...babelOptions }, | |||
ecmaVersion, | |||
ecmaVersion: ecmaVersion === "latest" ? 2020 : ecmaVersion, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest is 2022 as of August 2021. I think we can normalize "latest"
to 1e8
like acorn did (https://github.com/acornjs/acorn/blob/691a31b1e3d6936f4e6991da3d81c1a6b06610cf/acorn/src/options.js#L109) so we don't have to update it every year.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See you again in 99997979 years to update this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't miss the date.
"latest"
as ecmaVersion
"latest"
as ecmaVersion
Ref eslint/eslint#14720